package com.brandongogetap.stickyheaders.demo.tools;

import com.brandongogetap.stickyheaders.model.HeaderModel;
import com.brandongogetap.stickyheaders.model.ItemModel;
import com.brandongogetap.stickyheaders.tools.Utils;
import org.junit.Assert;
import org.junit.Test;

import java.util.List;

public class UtilsTest {

    @Test
    public void testDemoListSize() {
        List<ItemModel> demoList = Utils.demoList();
        Assert.assertEquals(100, demoList.size());
    }

    @Test
    public void testDemoListHeaderEntry() {
        List<ItemModel> demoList = Utils.demoList();
        HeaderModel headerModel = (HeaderModel) demoList.get(12);
        Assert.assertEquals("Header at 12", headerModel.getTitle());
        Assert.assertEquals("", headerModel.getMessage());
    }

    @Test
    public void testDemoListHeaderPaddings() {
        int[] paddings = new int[]{0, 100, 0, 100};
        List<ItemModel> demoList = Utils.demoList();
        HeaderModel headerModel = (HeaderModel) demoList.get(12);
        int[] realPaddings = headerModel.getPaddings();
        int size = paddings.length;
        for (int i = 0; i < size; i++) {
            Assert.assertEquals(paddings[i], realPaddings[i]);
        }
    }

    @Test
    public void testDemoListEntry() {
        List<ItemModel> demoList = Utils.demoList();
        ItemModel itemModel = (ItemModel) demoList.get(1);
        Assert.assertEquals("Item at 1", itemModel.getTitle());
        Assert.assertEquals("Item description at 1", itemModel.getMessage());
    }
}